import request from './request'
import type { HomeData, Product, News, PaginatedResponse } from '@/types'

// 获取首页数据
export const getHomeData = () => {
  return request<HomeData>({
    url: '/portal/home',
    method: 'get'
  })
}

// 获取产品列表
export const getProducts = (params: { page: number; page_size: number; keyword?: string }) => {
  return request<PaginatedResponse<Product>>({
    url: '/portal/products',
    method: 'get',
    params
  })
}

// 获取产品详情
export const getProductDetail = (id: number) => {
  return request<Product>({
    url: `/portal/products/${id}`,
    method: 'get'
  })
}

// 获取新闻列表
export const getNewsList = (params: { page: number; page_size: number; keyword?: string }) => {
  return request<PaginatedResponse<News>>({
    url: '/portal/news',
    method: 'get',
    params
  })
}

// 获取新闻详情
export const getNewsDetail = (id: number) => {
  return request<News>({
    url: `/portal/news/${id}`,
    method: 'get'
  })
}

// 获取套餐页面数据（所有启用的套餐）
export const getPackagesData = () => {
  return request<{
    service_packages: any[]
    custom_packages: any[]
    package_features: any[]
    faqs: any[]
  }>({
    url: '/portal/packages',
    method: 'get'
  })
}

